﻿#pragma once

#include "ISoundLibrary.h"
#include <string>
#include <vector>
#include "../../../tangible_filesystem.h"
#include "../../../disposable_interface.h"

using namespace SlimDX::DirectSound;
using namespace SlimDX::Multimedia;

namespace Client::MirSounds
{
    class WavLibrary : public ISoundLibrary, public Disposable
    {
    private:
        int Index = 0;

    public:
        virtual ~WavLibrary()
        {
            delete _stream;
            delete _desc;
        }

        int getIndex() const override;
        void setIndex(int value) override;

    private:
        std::vector<SecondarySoundBuffer*> _bufferList;
        WaveStream *_stream;

        bool _loop = false;

        SoundBufferDescription *_desc;
        const std::vector<unsigned char> _data;

    public:
        static WavLibrary *TryCreate(int index, const std::string &fileName, bool loop);

        WavLibrary(int index, const std::string &fileName, bool loop);

        void Play() override;

        void Stop() override;

        void Dispose() override;

        void SetVolume(int vol) override;
    };
}
